<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3/dist/echarts.min.js"></script>
</head>

<body>
    <!-- 为 ECharts 准备一个定义了宽高的 DOM -->
    <div id="main" style="width: 600px;height:400px;"></div>
</body>
<script type="text/javascript">
    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('main'));

    // 指定图表的配置项和数据
    var option = {
        title: {
            text: 'Temperature Change in the Coming Week'
        },
        tooltip: {
            trigger: 'axis'
        },
        legend: {},
        toolbox: {
            show: true,
            feature: {
                dataZoom: {
                    yAxisIndex: 'none'
                },
                dataView: { readOnly: false },
                magicType: { type: ['line', 'bar'] },
                restore: {},
                saveAsImage: {}
            }
        },
        xAxis: {
            type: 'category',
            boundaryGap: false,
            data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
        },
        yAxis: [
            {
                name: '温度',
                type: 'value',
                // axisLabel: {
                //     formatter: '{value} °C'
                // }
            },
            {
                type: 'value',
                name: '概率',
                axisLabel: {
                    show: true,
                    // interval: 'auto',
                    formatter: '{value} %'
                }
            }
        ],
        series: [
            {
                name: 'Highest',
                type: 'line',
                data: [10, 11, 13, 11, 12, 12, 9],
                yAxisIndex: 0,
                markPoint: {
                    data: [
                        { type: 'max', name: 'Max' },
                        // { type: 'min', name: 'Min' }
                    ]
                },
                markLine: {
                    data: [{ type: 'max', name: 'Max' }],

                    label: {
                        color: 'orange',
                        position: "insideStartTop",
                        formatter: (data) => {
                            return `峰值${data.value}`
                        }
                    },
                    lineStyle: {
                        color: 'orange',
                        width: 3
                    }
                }
            },
            {
                name: 'Lowest',
                type: 'line',
                data: [20, -20, 20, 50, 30, 20, 0],
                yAxisIndex: 1,
                markPoint: {
                    data: [{ name: '周最低', value: -2, xAxis: 1, yAxis: -1.5 }]
                },
                markLine: {
                    data: [
                        { type: 'average', name: 'Avg' },
                        [
                            {
                                symbol: 'none',
                                x: '90%',
                                yAxis: 'max'
                            },
                            {
                                symbol: 'circle',
                                label: {
                                    position: 'start',
                                    formatter: 'Max'
                                },
                                type: 'max',
                                name: '最高点'
                            }
                        ]
                    ]
                }
            }
        ]
    };

    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);
</script>

</html>